package com.example.acitvemqspringbootdemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
@RequestMapping("/activemq")
public class ControllerDemo {

     @Autowired
     Producer producer;

    @GetMapping("/simple" )
    public String simpleSender(){
        producer.send();
        return "Simple Message";
    }

    @GetMapping("/sreply/{listenerNum}" )
    public String simpleSendReply(@PathVariable int listenerNum) throws Exception{
        producer.sendReply(listenerNum);
        return "Send and Reply";
    }

    @GetMapping("/sreceive" )
    public String simpleSendReceive() throws Exception{
        producer.sendReceive();
        return "Send and Receive";
    }

    @GetMapping("/transaction" )
    public String transactionSend () {
        producer.transactionProducer();
        return "Send Transaction";
    }

    @GetMapping("/durable" )
    public String durableSend () {
        producer.durableProducer();
        return "Send Durable";
    }

    @GetMapping("/ack")
    public String ackSender(){
        producer.ackProducer();
        return "ack Message";
    }

    @GetMapping("/dead")
    public String deadSender(){
        producer.deadProducer();
        return "dead Message";
    }

    @GetMapping("/delay")
    public String delaySender(){
         producer.delayProducer();
        return "delay Message";
    }

    @GetMapping("/scallback")
    public String scallSender(){
        producer.sendBySessionCallback();
        return "SessionCallback Message";
    }

    @GetMapping("/pcallback")
    public String pcallSender(){
        producer.sendByProducerCallback();
        return "ProducerCallback Message";
    }
}
